<div class="control-group">
    <div class="controls">
        <!--            --><?php //echo CHtml::image($model->image) ?>
        <?php
        $url = $this->createUrl('/Xpress/service/ajax');
        $this->widget('Gallery.components.widgets.GalleryManagerWidget', array(
            'model' => $model,
            'attribute' => 'gallery',
            'beforeDelete' => 'function(d,id){
    $.get(
        \'' . $url . '\',
        {
            SID : \'Shop.Product.usedGallery\',
            galleryId: id
        }
    ).done(function(res){
        res = eval(res);
        if (res.status != undefined && res.status == 0)
            d.resolve();
        else
        {
            alert("You can not delete gallery when it is used");
            d.reject();
        }
    }).fail(d.reject);
}'
        ));
        echo CHtml::link('<i class="icon-remove"></i>', '#', array('class' => 'unlink-gallery' . (empty($model->gallery) ? ' hide' : '')));
        $baseUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('Gallery.components.widgets.*') . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'galleries');
        app()->clientScript->registerScript(__CLASS__ . 'UnlinkGallery', "$('.unlink-gallery').click(function(){
        $('#Product_gallery').val('');
        $('.choose-gallery img').attr('src','" . $baseUrl . "/images/no_image.jpg');
        $(this).addClass('hide');
        return false;
        });");
        ?>
    </div>
</div>